// pages/detail/detail.js
const api = require('../../api/api.js')
Page({
  data: {
    filmId: '',
    film: {},
    start: 0,
    count: 10,
    comments: []
  },
  onLoad: function (option) {
    this.data.filmId = option.filmId
    console.log()
  },
  onReady: function () {
    this.loadDetailData()
  },
  loadDetailData () {
    api.loadFilmByFilmId(this.data.filmId)
      .then(data => {
        this.setData({
          film: data
        })
      }).catch(api.showError)
    
    api.loadCommentByFilmId(this.data.filmId, {
      start: this.data.start,
      count: this.data.count,
      order_by: 'time'
    }).then(data => {
      console.log(data)
      this.setData({
        comments: data.interests
      })
    }).catch(api.showError)
  }
})